home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 3
/
ct-rom iiib.zip
/
ct-rom iiib
/
CTSELECT
/
TERMINAT
/
0150TER2._XE
/
PASCAL.EXE
/
LSTPHONE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-07-22
|
1KB
|
47 lines
Program ListPhoneBook;
{ A small Terminate utility to show how to use the phonebook }
{$I PHONE.100}
Var
PhoneFile : File;
x : Word;
Procedure FatalError(s:string);
Begin
WriteLn('Fatal: '+s+#10#10);
Halt;
End;
Begin
FillChar(PHead,Sizeof(PHead),0);
Assign(PhoneFile,'TERMINAT.FON');
{$I-} Reset(PhoneFile,1); {$I+}
If IOResult=0 Then
Begin
{ Read the header in the phone file }
{$I-} BlockRead(PhoneFile,PHead,Sizeof(PHead)); {$I+}
If IOResult<>0 Then FatalError('Error in start of phonebook');
{ Read all records into structure }
For x:=1 to PHead.Num Do
Begin
New(Ph[x]); { Reserve memory }
{$I-} BlockRead(PhoneFile,Ph[x]^.P,Sizeof(Ph[x]^.P)); {$I+}
If IOResult<>0 Then FatalError('Error in phonebook, maybe wrong version');
End;
Close(PhoneFile);
End;
{ Write all phonenumbers on screen }
For x:=1 to PHead.Num Do WriteLn(Ph[x]^.P.Name);
{ Free memory before exiting }
For x:=1 to PHead.Num Do Dispose(Ph[x]);
End.